
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "usr_wdt.h"

#define LOG_TAG     "wdt"
#define LOG_LVL     LOG_LVL_DBG
#include <ulog.h>
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported functions prototypes ---------------------------------------------*/
/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
static rt_device_t wdt_t;

/* USER CODE END PV */

/* Private user code ---------------------------------------------------------*/

/* USER CODE BEGIN */

static void idle_hook(void) 
{
    /* 在 空 闲 线 程 的 回 调 函 数 里 喂 狗 */
   rt_device_control(wdt_t, RT_DEVICE_CTRL_WDT_KEEPALIVE, NULL);
}

int wdt_init(void)
{
    uint32_t timeout = WDT_DEVICE_WEED_DOG_TIME;
    
    wdt_t = rt_device_find("wdt");
  
    RT_ASSERT(wdt_t != RT_NULL);
        
    rt_device_init(wdt_t);
    rt_device_control(wdt_t, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, &timeout);
    rt_device_control(wdt_t, RT_DEVICE_CTRL_WDT_START, RT_NULL);
    rt_thread_idle_sethook(idle_hook);
  
    return 0;
}
//INIT_COMPONENT_EXPORT(wdt_init);


/* USER CODE END */

